﻿Imports System.Runtime.CompilerServices

Namespace Xhtml
    Public Module RenderPartialExtensions

        ' Renders the partial view with the parent's view data
        <Extension()> _
        Public Function RenderPartial(ByVal xHelper As XhtmlHelper, ByVal view As VbView) As XElement
            Return xHelper.RenderPartialInternal(view, xHelper.ViewData, Nothing)
        End Function

        ' Renders the partial view with the given view data
        <Extension()> _
        Public Function RenderPartial(ByVal xHelper As XhtmlHelper, ByVal view As VbView, ByVal viewData As ViewDataDictionary) As XElement
            Return xHelper.RenderPartialInternal(view, viewData, Nothing)
        End Function

        ' Renders the partial view with an empty view data and the given model
        <Extension()> _
        Public Function RenderPartial(ByVal xHelper As XhtmlHelper, ByVal view As VbView, ByVal model As Object) As XElement
            Return xHelper.RenderPartialInternal(view, xHelper.ViewData, model)
        End Function

        ' Renders the partial view with a copy of the given view data plus the given model
        <Extension()> _
        Public Function RenderPartial(ByVal xHelper As XhtmlHelper, ByVal view As VbView, ByVal model As Object, ByVal viewData As ViewDataDictionary) As XElement
            Return xHelper.RenderPartialInternal(view, viewData, model)
        End Function

    End Module
End Namespace